package com.ldcc.report_system.ui.guide_page;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import com.ldcc.report_system.ApplicationConfig;
import com.ldcc.report_system.ReportApplication;
import com.ldcc.report_system.adapter.GuidePageAdapter;
import com.ldcc.report_system.databinding.ActivityGuidePageBinding;
import com.ldcc.report_system.databinding.GuidePageItemBinding;
import com.ldcc.report_system.util.SharedPreferencesUtils;
import com.ldcc.report_system.util.WindowUtils;

public class GuidePageActivity extends AppCompatActivity {

    private ActivityGuidePageBinding guidePageBinding;

    private GuidePageItemBinding guidePageItemBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.guidePageBinding = ActivityGuidePageBinding.inflate(getLayoutInflater());
        this.guidePageItemBinding = GuidePageItemBinding.inflate(getLayoutInflater());
        setContentView(this.guidePageBinding.getRoot());
        Context context = ReportApplication.getContext();
        // 设置第一次打开软件的 value 为 false
        SharedPreferencesUtils.setParam(context, ApplicationConfig.IS_FIRST_USE, false);
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        this.initPage();
    }

    /**
     * 初始化页面
     */
    private void initPage() {
        // 设置界面顶部为透明
        WindowUtils.setWindowTopTransparent(getWindow());
        // 隐藏虚拟按键
        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE;
        window.setAttributes(params);
        GuidePageAdapter guidePageAdapter = new GuidePageAdapter(this);
        ViewPager2 viewPager = guidePageBinding.guidePage;
        viewPager.setAdapter(guidePageAdapter);
    }
}